<cfscript>    
    view = createObject("component", session.rootDir & ".views.layout");
    if( Session.Auth EQ True and (Session.strAuthType EQ Session.IT or Session.strAuthType EQ Session.HR) ){
        view.init("Badge Creation Report","","","Home",index);
    }else{
        view.init("Denied","","","Home","Denied");
    }    
    view.html();
</cfscript>

<cffunction name="index" access="public" output="true" returntype="any">
    <cfscript>
        import models.*;
        KronosQueries = CreateObject("component", session.rootDir & ".DatabaseQueries.Kronos");
        if( isDefined('URL.StepID') ){
            StepActions = ORMExecuteQuery("FROM StepActions WHERE StepActionsID = " & URL.StepID & " AND ActTimeStamp IS NULL");
        }else{
            StepActions = ORMExecuteQuery("FROM StepActions WHERE StepsID = 5 AND ActTimeStamp IS NULL AND TermReqID IS NULL");
            URL.StepID = -1;
        }
        FormAction = "/#session.rootDir#/Controller/SubmitHandler.cfm?SCFStep4=printbadge";
    </cfscript>
    <script language="javascript">
        window.print();
    </script>
    <h1 class="title">Badge Creation Report</h1>
    <div class="entry">
        <cfform name="frmStep4" method="post" action="#FormAction#">        
            <cfinput type="hidden" name="StepID" value="#URL.StepID#" />    
            <table width = 100%>
                <tr>
                    <td>&nbsp;</td> 
                </tr>
                <tr>
                    <td valign="bottom"><u>##</u></td> 
                    <td valign="bottom"><strong><u>Name</u></strong></td>
                    <td valign="bottom"><strong><u>Job Title</u></strong></td>
                    <td valign="bottom"><strong><u>Department</u></strong></td>
                </tr>
                
                <cfloop from="1" to="#ArrayLen(StepActions)#" index="i">
                    <cfset Employee = ORMExecuteQuery("FROM Employee WHERE EmployeeID = " & StepActions[i].getEmployeeID() & " AND NonSCFTypeID IS NULL") />
                    <cfif ArrayLen(Employee) NEQ 0>
                        <cfset PositionInfo = KronosQueries.funcGetPositionInfo(Employee[1].getPositionID()) />
                        <cfset Depts = KronosQueries.funcGetDepts(Employee[1].getDepartmentID()) />
                        <tr>
                            <td>#i#)</td>  
                            <td valign="bottom">#Employee[1].getFirstName()# #Employee[1].getLastName()#</td>
                            <td valign="bottom">#PositionInfo.PositionCodeDescription#</td>
                            <td valign="bottom">#Depts.OrganizationDescription#</td> 
                        </tr>
                    </cfif>
                </cfloop>
                
            </table>          
        </cfform>
    </div>

</cffunction>